<?php
include '../Class/Facebook/facebook.php';
//include $_SERVER['DOCUMENT_ROOT'].'/project/Class/Facebook/facebook.php';
$facebook = new Facebook(array(
  'appId'  => '145809745587554',
  'secret' => '622a5e039f56d69576954c0224dc6fbd',
  'fileUpload' => true,
  'cookie' => true,  
));

// Get User ID
$fb_user = $facebook->getUser();
if($fb_user){
  try{
    // Proceed knowing you have a logged in user who's authenticated.
    $fb_userData=$facebook->api('/me');
  }catch(FacebookApiException $e) {
    error_log($e);
    $user=null;
    $facebook->destroySession();
    session_destroy();
  }
}
if(isset($_GET['logout'])){
	$facebook->destroySession(null); 	
	header("Location:".$_SERVER['PHP_SELF']);
}
// Login or logout url will be needed depending on current user state.
if($fb_user){
  $logoutUrl = $facebook->getLogoutUrl(array(
  	"next"=>"http://".$_SERVER['SERVER_NAME']."/project/Controller/FbLogout.php"
  ));
} else{
  $loginUrl = $facebook->getLoginUrl(array(
  	"redirect_uri"=>"http://".$_SERVER['SERVER_NAME']."/project/Controller/FbCheckLogin.php",
	"display"=>"popup",
	"scope"=>"publish_stream,user_birthday,user_location"
  ));
}
?>